import { reqCategoryListData, reqBannerListData,reqFloorsListData } from '@/api'

const state = {
    //三级导航
    categoryList: [],
    // 存储轮播图数据
    bannerList: [],
    //楼层数据
    floorsList: []
}

const actions = {
    //三级导航
    async getCategoryListData(context) {
        const result = await reqCategoryListData()
        // console.log('三级导航',result);
        if (result.code === 200) {
            context.commit('SAVE_CATEGORY_LIST_DATA', result)
        }
        // console.log(result);
    },
    //轮播图
    async getBannerListData({ commit }) {
        const result = await reqBannerListData()
        if (result.code === 200) {
            commit('SAVE_BANNER_LIST_DATA', result)
        }
        // console.log(result);
    },
    //楼层
    async getFloorsListData({ commit }) {
        const result = await reqFloorsListData()
        // console.log('楼层',result);
        if (result.code === 200) {
            commit('SAVE_FLOORS_LIST_DATA', result.data)
        }
    }

}

const mutations = {
    //三级导航
    SAVE_CATEGORY_LIST_DATA(state, payload) {
        // console.log(payload);
        state.categoryList = payload.data
    },
    //轮播图
    SAVE_BANNER_LIST_DATA(state, payload) {
        // console.log(payload);
        state.bannerList = payload.data
    },
    //楼层
    SAVE_FLOORS_LIST_DATA(state, payload) {
        state.floorsList = payload
    }

}

const getters = {}


export default {
    namespaced: true,
    state,
    actions,
    mutations,
    getters
}